import {
  Monitor,
  PictureRounded,
  SetUp,
  Document,
  User,
  HomeFilled,
  Files,
  Picture,
  EditPen,
  Share,
  Upload,
  List,
  Delete,
  Histogram,
  DataAnalysis,
  PictureFilled,
  UserFilled,
  DocumentCopy,
  Key,
  View,
  Lock,
  Notebook,
  Message,
  Operation,
  MoreFilled,
  Setting,
  TrendCharts,
  Odometer,
  Tickets,
  Grid,
  Management,
  Menu,
  Tools,
  CreditCard,
  Collection,
  DArrowRight,
  Connection,
  Cpu,
  Postcard,
  Discount,
  CircleCheck,
  Opportunity,
  PieChart,
  DataLine,
  DataBoard,
  Platform,
  CollectionTag,
  Guide,
  // AppHeader 组件需要的图标
  Fold,
  Expand,
  Bell,
  FullScreen,
  Close,
  ArrowDown,
  SwitchButton,
  Compass,
  QuestionFilled
} from '@element-plus/icons-vue'

/**
 * 图标映射对象
 */
const iconMap: Record<string, any> = {
  'system': Setting,
  'user': User,
  'users': User,
  'peoples': UserFilled,
  'tree-table': List,
  'lock': Lock,
  'form': Document,
  'logininfo': Operation,
  'login': Operation,
  'edit': EditPen,
  'server': Monitor,
  'file': Files,
  'files': Files,
  'share': Share,
  'upload': Upload,
  'documentlist': DocumentCopy,
  'list': List,
  'picturelist': PictureFilled,
  'delete': Delete,
  'picture': Picture,
  'documentation': Notebook,
  'chart': DataLine,
  'databoard': DataBoard,
  'piechart': PieChart,
  'dataline': DataLine,
  'histogram': Histogram, 
  'eye-open': View,
  'view': View,
  'password': Key,
  'message': Message,
  'dashboard': HomeFilled,
  'data-analysis': DataAnalysis,
  'analysis': DataAnalysis,
  'more': MoreFilled,
  'monitor': Monitor,
  'tickets': Tickets,
  'grid': Grid,
  'setup': SetUp, 
  'management': Management,
  'settings': Setting,
  'odometer': Odometer,
  'menu': Menu,
  'tools': Tools,
  'credit-card': CreditCard,
  'collection': Collection,
  'arrow-right': DArrowRight,
  'connection': Connection,
  'cpu': Cpu,
  'postcard': Postcard,
  'discount': Discount,
  'check': CircleCheck,
  'opportunity': Opportunity,
  'platform': Platform,
  'tag': CollectionTag,
  'guide': Guide,
  // AppHeader 图标映射
  'fold': Fold,
  'expand': Expand,
  'bell': Bell,
  'notification': Bell,
  'fullscreen': FullScreen,
  'close': Close,
  'arrow-down': ArrowDown,
  'switch': SwitchButton,
  'compass': Compass,
  'question': QuestionFilled
}

/**
 * 根据图标名称获取对应的图标组件
 * @param iconName 图标名称
 * @returns 对应的图标组件
 */
export const getIcon = (iconName: string) => {
  // 如果传入的图标名为空，使用默认图标
  if (!iconName) {
    return Monitor
  }
  
  // 统一处理图标名称，转为小写防止大小写不一致
  const normalizedName = typeof iconName === 'string' ? iconName.toLowerCase() : ''
  
  // 尝试直接通过图标名获取
  let icon = iconMap[normalizedName]
  
  // 如果没有找到，尝试通过去除特殊字符的方式获取
  if (!icon) {
    // 去除特殊字符后尝试匹配
    const simpleName = normalizedName.replace(/[^a-z0-9]/g, '')
    icon = iconMap[simpleName]
    
    if (icon) {
    }
  }
  
  // 如果还未找到，使用默认图标
  if (!icon) {
    icon = Monitor
  } else {
  }
  
  return icon
}

/**
 * 导出所有图标
 */
export const Icons = {
  Monitor,
  PictureRounded,
  SetUp,
  Document,
  User,
  HomeFilled,
  Files,
  Picture,
  EditPen,
  Share,
  Upload,
  List,
  Delete,
  Histogram,
  DataAnalysis,
  PictureFilled,
  UserFilled,
  DocumentCopy,
  Key,
  View,
  Lock,
  Notebook,
  Message,
  Operation,
  MoreFilled,
  Setting,
  TrendCharts,
  Odometer,
  Tickets,
  Grid,
  Management,
  Menu,
  Tools,
  CreditCard,
  Collection,
  DArrowRight,
  Connection,
  Cpu,
  Postcard,
  Discount,
  CircleCheck,
  Opportunity,
  PieChart,
  DataLine,
  DataBoard,
  Platform,
  CollectionTag,
  Guide,
  // AppHeader 图标
  Fold,
  Expand,
  Bell,
  FullScreen,
  Close,
  ArrowDown,
  SwitchButton,
  Compass,
  QuestionFilled
} 